-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add nudge braze email using commands #388
Conversation
9fa20d4
to
fc242fb
Compare
@@ -104,7 +104,7 @@ class AssignmentAutomaticExpiredReason: | |||
""" | |||
Reason for assignment automatic expiry. | |||
""" | |||
NIENTY_DAYS_PASSED = 'NIENTY_DAYS_PASSED' | |||
NINETY_DAYS_PASSED = 'NINETY_DAYS_PASSED' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noticed a typo in this constant, refactored all cases where its used with the correct spelling for the value and variable
e8ece62
to
af3d2ed
Compare
5cba6e6
to
c62d751
Compare
c62d751
to
c735a39
Compare
...prise_access/apps/content_assignments/management/commands/automatically_nudge_assignments.py
Outdated
Show resolved
Hide resolved
...prise_access/apps/content_assignments/management/commands/automatically_nudge_assignments.py
Outdated
Show resolved
Hide resolved
...prise_access/apps/content_assignments/management/commands/automatically_nudge_assignments.py
Outdated
Show resolved
Hide resolved
...s/apps/content_assignments/management/commands/tests/test_automatically_nudge_assignments.py
Outdated
Show resolved
Hide resolved
...prise_access/apps/content_assignments/management/commands/automatically_nudge_assignments.py
Show resolved
Hide resolved
...s/apps/content_assignments/management/commands/tests/test_automatically_nudge_assignments.py
Outdated
Show resolved
Hide resolved
This is the main thing to fix (plus tests) and the reason for requesting changes. |
Ah, I misunderstood the intent here. The fact that we're sending reminders made me think you wanted allocated assignments. But you actually do want accepted ones. Let's take this conv off github for now, I think there's some nuance here. |
55c6222
to
456b4e5
Compare
456b4e5
to
03ff109
Compare
c11dcf9
to
4c9dba8
Compare
4c9dba8
to
e1d2c2d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking really good!
class LearnerContentAssignmentNudgeRequestSerializer(serializers.Serializer): | ||
""" | ||
Request serializer to validate nudge endpoint query params. | ||
|
||
For view: LearnerContentAssignmentAdminViewSet.nudge | ||
""" | ||
assignment_uuids = serializers.ListField( | ||
child=serializers.UUIDField(), | ||
allow_empty=False | ||
) | ||
days_before_course_start_date = serializers.IntegerField( | ||
min_value=1 | ||
) | ||
|
||
|
||
class LearnerContentAssignmentNudgeResponseSerializer(serializers.Serializer): | ||
""" | ||
Response serializer for nudge endpoint. | ||
|
||
For view: LearnerContentAssignmentAdminViewSet.nudge | ||
""" | ||
nudged_assignment_uuids = serializers.ListField( | ||
child=serializers.UUIDField(), | ||
) | ||
unnudged_assignment_uuids = serializers.ListField( | ||
child=serializers.UUIDField(), | ||
) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very nice
enterprise_access/apps/api/v1/views/content_assignments/assignments_admin.py
Outdated
Show resolved
Hide resolved
enterprise_access/apps/content_assignments/content_metadata_api.py
Outdated
Show resolved
Hide resolved
...prise_access/apps/content_assignments/management/commands/automatically_nudge_assignments.py
Show resolved
Hide resolved
...s/apps/content_assignments/management/commands/tests/test_automatically_nudge_assignments.py
Show resolved
Hide resolved
11a2d75
to
5e9d818
Compare
5e9d818
to
197af37
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved, but please address that **kwargs
thing before merging. 👍
@extend_schema( | ||
tags=[CONTENT_ASSIGNMENT_ADMIN_CRUD_API_TAG], | ||
summary='Nudge assignments by UUID.', | ||
request=LearnerContentAssignmentNudgeRequestSerializer, | ||
parameters=None, | ||
responses={ | ||
status.HTTP_200_OK: LearnerContentAssignmentNudgeResponseSerializer, | ||
status.HTTP_422_UNPROCESSABLE_ENTITY: None, | ||
} | ||
) | ||
@permission_required(CONTENT_ASSIGNMENT_ADMIN_WRITE_PERMISSION, fn=assignment_admin_permission_fn) | ||
@action(detail=False, methods=['post']) | ||
def nudge(self, request, *args, **kwargs): | ||
""" | ||
Send nudges to a list of learners with associated ``LearnerContentAssignment`` | ||
record by list of uuids. | ||
|
||
``` | ||
Raises: | ||
400 If assignment_uuids list length is 0 or the value for days_before_course_start_date is less than 1 | ||
422 If the nudge_assignments call fails for any other reason | ||
``` | ||
""" | ||
serializer = LearnerContentAssignmentNudgeRequestSerializer(data=request.data) | ||
serializer.is_valid(raise_exception=True) | ||
assignment_configuration_uuid = self.requested_assignment_configuration_uuid | ||
assignments = self.get_queryset().filter( | ||
assignment_configuration__uuid=assignment_configuration_uuid, | ||
uuid__in=serializer.data['assignment_uuids'], | ||
) | ||
days_before_course_start_date = serializer.data['days_before_course_start_date'] | ||
try: | ||
result = assignments_api.nudge_assignments( | ||
assignments, | ||
assignment_configuration_uuid, | ||
days_before_course_start_date | ||
) | ||
response_serializer = LearnerContentAssignmentNudgeResponseSerializer(data=result) | ||
response_serializer.is_valid(raise_exception=True) | ||
return Response(data=response_serializer.data, status=status.HTTP_200_OK) | ||
except Exception: # pylint: disable=broad-except | ||
return Response(status=status.HTTP_422_UNPROCESSABLE_ENTITY) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a really, really well-factored and well-documented view, with really clear validation and abstractions around our business logic. Nice work, hang this on your fridge!
enterprise_access/apps/content_assignments/content_metadata_api.py
Outdated
Show resolved
Hide resolved
8949677
to
8ccb407
Compare
8ccb407
to
937d012
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creates a command to send nudge emails to accepted assignments that are 14 and 30 days in advance for only executive education courses.